<!DOCTYPE html>
<?php 
$contents = '<h1>great1</h1>';
	if (isset($_REQUEST['editor1'])){
		$contents = $_REQUEST['editor1'];
	}
?>
<html>
<head>
	<title>Replace Textarea by Code &mdash; CKEditor Sample</title>
	<meta charset="utf-8">
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
	<script src="../ckeditor.js"></script>
	<link href="../my.css" rel="stylesheet">
	<script type="text/javascript">
	$(function() {
		$("#button-preview").click(function(){
//			$("#preview").load("mypreview.php",{editor1:$('#editor1').val()});
			alert(document.commit.target); 
			document.commit.target = "preview";
			document.commit.action = 'mypreview2.php';
			document.commit.submit();
			document.commit.target = "_self";
		});
	});
</script>
</head>
<body>
	<h1 class="samples">
		<a href="index.html">CKEditor Samples</a> &raquo; Replace Textarea Elements Using JavaScript Code
	</h1>
	<form action="sample_posteddata.php" method="post" name="commit" target="_self" id="comm">
		<div><input type="text" name="pagetitle" /></div>
		<div class="description">
			<p>
				This editor is using an <code>&lt;iframe&gt;</code> element-based editing area, provided by the <strong>Wysiwygarea</strong> plugin.
			</p>
<pre class="samples">
CKEDITOR.replace( '<em>textarea_id</em>' )
</pre>
		</div>
		<textarea cols="80" id="editor1" name="editor1" rows="10">
			<?php echo $contents;?>
		</textarea>
		<script>

			// This call can be placed at any point after the
			// <textarea>, or inside a <head><script> in a
			// window.onload event handler.

			// Replace the <textarea id="editor"> with an CKEditor
			// instance, using default configurations.

			CKEDITOR.replace( 'editor1' );

		</script>
		<p>
			<input type="submit" value="Submit">
			<input type="button" value="preview" id="button-preview" />
		</p>
	</form>
	<ht />
	<div id="preview"><?php echo $contents;?></div>
	<div id="footer">
		<hr>
		<p>
			CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
		</p>
		<p id="copy">
			Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
			Knabben. All rights reserved.
		</p>
	</div>
</body>
</html>
